home *** CD-ROM | disk | FTP | other *** search
- The following is a Pascal assignment that I had in data structures. It
- implements a hash table and linked list for storing data using pointers. It is
- probably of use to you if you want to learn something about chain bucket
- hashing and pointers. Before digging into the code perhaps you want to get
- a book on data structures and read up on what hashing is. Happy computing!!
-
- Chris Maeder
-
-
- CHAIN BUCKET HASHING ASSIGNMENT
-
- Data Structures
- Fall 1985
-
- Write a program to store information about your friends/family/business
- associates using a hash table. The information kept on each person will be
- name, birthday, and address. For each record, hash on name.
-
- Use this hash function:
-
- Add the ordinal values of every character in the name but do not include
- any blanks. (It is OK to include the comma.) Then use the Mod function
- to keep the result in the range 0 to 12 (i.e. dimension the hash table
- from 0 to 12). The hashtable must be an array of pointers, not an array
- of records. Use chain bucket hashing to handle collisions. Each chain
- must be kept in sorted order to facilitate searching.
-
- Example input file:
-
- I Jones,Jack 07/20 1918 University Ave.
- I Smith,Bob 09/02 105 Langdon St.
- S Jones,Jack
- S Becker,Ann
- I Dodge,Ken 08/18 2102 Kendall Ave.
- D Smith,Bob
-
- An input record will start with I (for insert), S (for search), or D (for
- delete). Note the formats for S and D differ from I. Assume each input
- record is correct in its number and type of fields -- no error checking needed
- here.
-
- I means to insert a person into the hash table. Remember to keep each
- linked list sorted in ascending order.
-
- S means to search for that person's record and to print it out.
-
- D means to delete that person from the hash table (also dispose of the
- node).
-
- Notes:
-
- For S and D, it is possible the record will not exist in the table.
-
- The name field is of the form lastname,firstname with no blank in between.
- Consider this to be one field.
-
- Fields are separated by one blank.
-
- The maximum name size is 16 characters, birthday takes 5 characters, and
- the maximum address size is 25 characters (read until end of line).
-
- Output:
-
- Print a message for each input command stating what was done. Include
- printing the input values with labels. After this, print the hash table
- and its contents in the following manner:
-
- Table Index Names hashing to this index
- ----------- ---------------------------
-
- 0 Jones,Jack
- Smith,Bob
-
- 1 Becker,Ann
-
- 2 No one
-
- etc.